/* 缓存增强功能的额外样式 */

/* 日志条目样式 */
.log-entry {
    display: flex;
    align-items: flex-start;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.4;
    transition: background-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    height: 36px; /* 固定高度 */
    overflow: hidden;
}

.log-entry:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.log-timestamp {
    color: var(--text-secondary);
    margin-right: 12px;
    min-width: 140px;
    width: 140px;
    flex-shrink: 0;
    text-align: left;
}

.log-level {
    margin-right: 12px;
    min-width: 60px;
    width: 60px;
    flex-shrink: 0;
    font-weight: 600;
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    box-sizing: border-box;
}

.log-level-debug {
    background-color: rgba(107, 114, 128, 0.1);
    color: #4b5563;
}

.log-level-info {
    background-color: rgba(59, 130, 246, 0.1);
    color: #1e40af;
}

.log-level-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #92400e;
}

.log-level-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.log-level-exception {
    background-color: rgba(220, 38, 38, 0.15);
    color: #991b1b;
}

.log-level-emergency {
    background-color: rgba(153, 27, 27, 0.2);
    color: #7f1d1d;
}

.log-module {
    color: var(--primary-color);
    margin-right: 12px;
    min-width: 80px;
    width: 80px;
    flex-shrink: 0;
    font-weight: 500;
    text-align: left;
}

.log-message {
    flex: 1;
    color: var(--text-primary);
    word-break: break-word;
    text-align: left;
    width: calc(100% - 300px);
    box-sizing: border-box;
    overflow-wrap: break-word;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 设备项新日志指示器 */
.device-item.has-new-logs::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* 响应式样式 */
@media (max-width: 1024px) {
    .log-timestamp {
        min-width: 120px;
        width: 120px;
    }
    
    .log-module {
        min-width: 70px;
        width: 70px;
    }
    
    .log-message {
        width: calc(100% - 270px);
    }
}

@media (max-width: 768px) {
    .log-entry {
        flex-wrap: wrap;
    }
    
    .log-timestamp {
        min-width: 100px;
        width: 100px;
    }
    
    .log-level {
        min-width: 50px;
        width: 50px;
    }
    
    .log-module {
        min-width: 60px;
        width: 60px;
    }
    
    .log-message {
        width: 100%;
        margin-top: 6px;
        padding-left: 2px;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* 连接状态指示器 */
#status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    transition: background-color 0.3s ease;
}

#status-indicator.connecting {
    background-color: #f59e0b;
    animation: pulse 1s infinite;
}

#status-indicator.connected {
    background-color: #10b981;
}

/* 活跃按钮状态 */
.icon-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.icon-btn.active:hover {
    background-color: #1565c0;
}

/* 返回实时按钮 */
#back-to-realtime {
    background-color: var(--warning-color);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

#back-to-realtime:hover {
    background-color: #e68900;
    transform: translateY(-1px);
}

/* 会话组样式 */
.session-group {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.session-group.collapsed .session-logs {
    display: none;
}

.session-header {
    background-color: var(--background-color);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.session-header:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

.session-title {
    font-weight: 600;
    color: var(--text-primary);
}

.session-count {
    background-color: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.session-logs {
    background-color: white;
}

/* 空状态样式 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .material-icons {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--text-secondary);
}

.loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 响应式优化 */
@media (max-width: 768px) {
    .log-entry {
        flex-direction: column;
        gap: 4px;
        padding: 12px;
    }
    
    .log-timestamp,
    .log-level,
    .log-module {
        min-width: auto;
        margin-right: 0;
    }
    
    .log-level {
        align-self: flex-start;
    }
    
    .device-item.has-new-logs::after {
        top: 4px;
        right: 4px;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .log-entry {
        border-bottom-color: #000;
    }
    
    .log-level {
        border: 1px solid currentColor;
    }
    
    #status-indicator {
        border: 1px solid #000;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .device-item.has-new-logs::after,
    #status-indicator.connecting,
    .loading::before {
        animation: none;
    }
    
    .log-entry,
    .session-group,
    .session-header {
        transition: none;
    }
}